<?php
     define("MANS_",true);
	 require_once("./config.php");
	 $page_title = !empty($page_title) ? $page_title :'Man0sions';
	 $sm->assign('page_title',	$page_title);
	
	 if($act=='login')
	 {
		$sm->display('login.htm',$cache_id);
		exit();
	 }
	 elseif($act=='logins')
	 {
		$data = !empty($_POST['data']) ? $Main->json2Array(stripcslashes($_POST['data'])) : '' ;
		
		$user_name = $data['user_name'];
		$passwd = md5($data['passwd']);
		$m_key = @$data['m_key'];
		$sql = "select * from admin_user where user_name='".$user_name."' and password='".$passwd."'";
		$row = $GLOBALS['db']->getRow($sql);
		if($row)
		{
			$_SESSION['admin']['user_name'] = $data['user_name'];
			$_SESSION['admin']['passwd'] = $data['passwd'];
			die('1');

			if(!isset($_SESSION['m_key']))
			{
				$_SESSION['m_key'] = substr(md5(USER_AGENT),10,10);
			}

			if($m_key==$_SESSION['m_key'])
			{
				
			}
			else
			{
				$mail['to'] = array($user_name);
				$mail['subject'] = 'M_KEY'.$Main->dateFormat(time());
				$mail['body'] = 'M_KEY:'.$_SESSION['m_key'];
				$Main->sendMail($mail);
				die('0');
			}
		}
		die('');
	 }
	 elseif($act=='logout')
	 {
		unset($_SESSION['admin']);
		$Main->msg("安全退出","admins.php?act=login");
	 }
	 
	 if($no_style)
	 {
		$sm->display('no_style.htm');
	 }
	 else
	 {
		$sm->display('main.htm');
	 }
	
?>
